package org.example;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.sql.*;
import java.util.Properties;

public class JdbcConnectCode3 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, SQLException {
        Properties properties = new Properties();
        properties.load(new BufferedReader(new FileReader("first_git/src/main/resources/Jdbc.properties")));
        Class.forName(properties.getProperty("Driver"));
        String url= properties.getProperty("url");
        String user = properties.getProperty("user");
        String password=properties.getProperty("password");
        String sql ="select * from emp";
        Connection con = DriverManager.getConnection(url,user,password);
        Statement statement = con.createStatement();
        ResultSet resultSet = statement.executeQuery(sql);
        while (resultSet.next()){
            String ename = resultSet.getString("ename");
            System.out.println(ename);
        }
        statement.close();
        con.close();

    }

}
